﻿package base
{
	import com.dusk.game.Logger;
	import com.dusk.net.AssetManager;
	import com.dusk.net.AssetType;
	import com.dusk.net.AssetUrl;
	import com.game.manager.GameSceneManager;
	import com.game.manager.NotificationManager;
	import com.game.view.layer.loadingBar.LoadingBar3;
	
	import flash.events.Event;
	
	public class BaseAsset
	{
		public function BaseAsset(param1:Class):void
		{
			targetClass = param1;
		}
		
		protected var assetName:String;
		protected var targetClass:Class;
		
		protected function loadAssets(param1:String):void
		{
			assetName = param1;
			var bar:LoadingBar3 = new LoadingBar3();
			GameSceneManager.getIns().addScene(bar);
			AssetManager.getIns().addCallback(bar.onComplete,bar.onProgress);
			AssetManager.getIns().loadAsset(AssetUrl.getInterFaceAssetsUrl(assetName),AssetType.SWF,null,__onComplete,null,__onFailed);
		}
		
		protected function destroy():void
		{
			assetName = "";
		}
		
		protected function __onComplete(param1:Event = null):void
		{
			GameSceneManager.getIns().addScene(new targetClass());
			destroy();
		}
		
		protected function __onFailed(param1:Event = null):void
		{
			Logger.logError("文件 " + assetName + " 加载失败！",this);
			NotificationManager.alert("文件 " + assetName + " 加载失败！", 3);
			destroy();
		}
	}
}